// 配置路由守卫
import router from "./router";
import local from "./utils/local";

// 配置路由守卫
router.beforeEach((to,from,next)=>{
    let tk = local.get("tk");
    let whiteList = ["/login","/404"]; // 白名单
    // 判断有没有token
    if(tk){
        if( to.path == "/login" ){
            next({path: "/home/index"})
        }else{
            next();
        }
    }else{
        if( whiteList.includes(to.path) ){
            next();
        }else{
            next({path: "/login"});
            // 清空token和其他数据
            local.clear();
        }
    }
})






